/**
 * Title :	jFamilyTree generator
 * Description: jFamilyTree generator
 * Version:	provider
 * Copyright (c) 2001-2008
 * Terms of use:see license agreement at http://treebolic.sourceforge.net/en/license.htm
 * Author: Bernard Bou
 * Company: bsys
 */
package jFamilyTree.generator;

import java.awt.Color;
import java.io.IOException;
import java.net.URL;

import javax.swing.JEditorPane;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;

import jFamilyTree.Messages;

/**
 * HTML view
 * 
 * @author Bernard Bou
 */
public class HtmlView extends JEditorPane implements HyperlinkListener
{
	private static final long serialVersionUID = 1L;

	/**
	 * Constructor
	 */
	public HtmlView()
	{
		setText(Messages.getString("HtmlView.0")); //$NON-NLS-1$
		setContentType("text/html; charset=UTF-8"); //$NON-NLS-1$
		setForeground(Color.blue);
		setEditable(false);
		addHyperlinkListener(this);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.swing.event.HyperlinkListener#hyperlinkUpdate(javax.swing.event.HyperlinkEvent)
	 */
	public void hyperlinkUpdate(HyperlinkEvent thisEvent)
	{
		if (thisEvent.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
		{
			URL thisURL = thisEvent.getURL();
			try
			{
				setPage(thisURL);
			}
			catch (IOException e)
			{
				setText(Messages.getString("HtmlView.1") + thisEvent.getURL()); //$NON-NLS-1$
			}
		}
	}
}